
#include <mem.h>

/* ------------------------------------------------------------------------- */

static uint8 ram_buf[RAM_FIX];

/* ------------------------------------------------------------------------- */

void fastcall ram_init(void)
{
	memset(ram_buf, 0, RAM_FIX);
}

uint32 fastcall ram_read(uint32 addr)
{
	uint32 data;

	if (addr >= RAM_FIX)
		return 0xffffffff;

	if (addr <= RAM_FIX - 4)
		return *(uint32 *)(&ram_buf[addr]);

	data = 0xffffffff;
	memcpy(&data, &ram_buf[addr], RAM_FIX - addr);
	return data;
}

void fastcall ram_write(uint32 addr, uint32 data)
{
	if (addr >= RAM_FIX)
		return;

	if (addr <= RAM_FIX - 4)
		*(uint32 *)(&ram_buf[addr]) = data;
	else
		memcpy(&ram_buf[addr], &data, RAM_FIX - addr);
}

/* ------------------------------------------------------------------------- */
